#!/bin/sh
# Copyright (c) 2011, bkil.hu
# This program is free software and can be distributed under the terms of
# the GNU General Public License v2,
# see COPYING for detailed licensing terms.
# created on 2011-02-22

main(){
 suspend_dbus
# suspend_devicekit
# suspend_upower
}

suspend_dbus(){
 DDEST="org.freedesktop.Hal"
 DPATH="/org/freedesktop/Hal/devices/computer"
 DINTERFACE="org.freedesktop.Hal.Device.SystemPowerManagement"
 DCOMMAND="Suspend"
 DARGS="int32:0"
 dbus
}

suspend_devicekit(){
 DDEST="org.freedesktop.DeviceKit.Power"
 DPATH="/org/freedesktop/DeviceKit/Power"
 DINTERFACE="org.freedesktop.DeviceKit.Power"
 DCOMMAND="Suspend"
 DARGS=""
 dbus
}

suspend_upower(){
 DDEST="org.freedesktop.UPower"
 DPATH="/org/freedesktop/UPower"
 DINTERFACE="org.freedesktop.UPower"
 DCOMMAND="Suspend"
 DARGS=""
 dbus
}

dbus(){
 dbus-send \
  --system \
  --print-reply \
  --dest=$DDEST \
  $DPATH \
  $DINTERFACE.$DCOMMAND \
  $DARGS
}

main "$@"
